package com.intozhou.yfl.activity;

import android.app.ProgressDialog;
import android.widget.Toast;

import com.infrastructure.activity.BaseActivity;
import com.infrastructure.net.RequestCallback;

/**
 * Created by zyt on 16/6/13 20:39 .
 * Email : syy19930112@aliyun.com
 * Description:
 * <p/>
 * 封装与业务相关的公用逻辑.
 */
public abstract class AppBaseActivity extends BaseActivity {
    protected ProgressDialog dlg;

    /**
     * 每个请求失败的错误回调提示大同小异,而请求成功的处理却千差万别,所以定义一个RequestCallback抽象类,实现{@link RequestCallback}接口并实现{@link RequestCallback#onFail(String)}方法.
     * <br>
     * 如果有的请求失败处理不一样,可以重写{@link AbstractRequestCallback#onSuccess(String)}方法实现个性化.
     */
    public abstract class AbstractRequestCallback implements RequestCallback {
        @Override
        public void onFail(String errorMessage) {
            dlg.dismiss();
            Toast.makeText(AppBaseActivity.this, errorMessage, Toast.LENGTH_SHORT).show();
        }
    }
}
